package com.yjz.designpattern.访问者模式;

import java.util.ArrayList;
import java.util.List;

// 对象结构
class ShoppingCart {
    private List<Element> items = new ArrayList<>();

    public void addItem(Element item) {
        items.add(item);
    }

    public void accept(Visitor visitor) {
        for (Element item : items) {
            item.accept(visitor);
        }
    }
}
